﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta name="viewport" content="width=device-width" />
    <link href="/Scripts/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="/Scripts/lib/json2.js" type="text/javascript"></script>
    <script src="/Scripts/lib/ligerUI/js/core/base.js" type="text/javascript"></script>
    <script src="/Scripts/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
    <script src="/Scripts/lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
    <script src="/Scripts/lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
    <script src="/Scripts/lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
    <script src="/Scripts/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="/Scripts/lib/ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
    <script src="/Scripts/lib/ligerUI/js/plugins/ligerSpinner.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(f_initGrid);
        var manager, g;
        function f_initGrid() {
            g = manager = $("#maingrid").ligerGrid({
                columns: [
                { display: '主键', name: 'id', width: 50, type: 'int', frozen: true },
                {
                    display: '关键字', name: 'name', width: 200,
                    editor: { type: 'select', url: '../../Manage/HotNav/GetParentdata', valueField: 'text' },
                },
                {
                    display: '操作', isSort: false, width: 220, render: function (rowdata, rowindex, value) {
                        var h = "";
                        if (!rowdata._editing) {
                            h += "<a href='javascript:beginEdit(" + rowindex + ")'>修改</a> ";
                            h += "<a href='javascript:deleteRow(" + rowindex + ")'>删除</a> ";
                        }
                        else {
                            h += "<a href='javascript:endEdit(" + rowindex + ")'>提交</a> ";
                            h += "<a href='javascript:cancelEdit(" + rowindex + ")'>取消</a> ";
                        }
                        return h;
                    }
                }
                ],
                onSelectRow: function (rowdata, rowindex) {
                    $("#txtrowindex").val(rowindex);
                },
                enabledSort: true,
                enabledEdit: true, clickToEdit: false, isScroll: false,
                url: '../../Manage/HotNav/Getdata',
                width: '100%'
            });
        }
        function beginEdit(rowid) {
            manager.beginEdit(rowid);
        }
        function cancelEdit(rowid) {
            manager.cancelEdit(rowid);
        }


        //调用方法 如

        function endEdit(rowid) {
            manager.endEdit(rowid);
            var str = getSelected();
            // $.post('Setdata', str);
            var row = manager.getSelectedRow();
            if (!row) { alert('请选择行'); return; }
            var str = JSON.stringify(row);
            $.post('../../Manage/HotNav/Setdata', JSON.parse(str));

        }

        function deleteRow(rowid) {
            if (confirm('确定删除?')) {
                var str = getSelected();
                // $.post('Setdata', str);
                var row = manager.getSelectedRow();
                if (!row) { alert('请选择行'); return; }
                var str = JSON.stringify(row);
                $.post('../../Manage/HotNav/Deldata', JSON.parse(str));
                manager.deleteRow(rowid);

            }
        }
        var newrowid = 100;
        function addNewRow() {
            manager.addEditRow();
        }

        function getSelected() {
            var row = manager.getSelectedRow();
            if (!row) { alert('请选择行'); return; }
            return JSON.stringify(row);
        }
        function getData() {
            var data = manager.getData();
            alert(JSON.stringify(data));
        }
        function addData() {
            manager.addEditRow();
        }
    </script>
</head>
<body style="padding:10px">
    <div class="l-clear"></div>
    <div id="maingrid" style="margin-top:20px"></div> <br />
    <button style="width:50px;height:30px;" onclick="addData()">添加</button>
    <div style="display:none;">
        <!-- g data total ttt -->
    </div>
</body>
</html>